package com.lcm.basic.p5.classz;

import java.lang.reflect.InvocationTargetException;

/**
 * java反射示例
 *
 *
 * @author Coder-lcm
 * @date 2021/3/31
 */
public class testClass {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        // 测试反射

//        Person p1 = new Person();
//        Method sayHello = Class.forName("com.lcm.basic.p5.classz.Person").getDeclaredMethod("sayHello", String.class);
//        Method sendMsg = Class.forName("com.lcm.basic.p5.classz.Person").getDeclaredMethod("sendMsg", String.class, String.class);
//        sayHello.invoke(p1,"lcm");
//        //对象 + 方法参数
//        sendMsg.invoke(p1,"lcm", "haha");
//        new Object();

        // 测试类型转换
//        String str1 = "str01";
//        System.out.println(str1 instanceof String);
//        System.out.println("dadaa" instanceof String);
//

        // 测试类
        Person person1 = new Person(1,"lcm");
        Person person2 = new Person(1, "lcm");
        System.out.println(person1 == person2);
        System.out.println(person1.equals(person2));
    }
}
